package cn.gson.crm.controller;

import cn.gson.crm.model.pojos.Category;
import cn.gson.crm.model.pojos.FunctionType;
import cn.gson.crm.model.pojos.categ;
import cn.gson.crm.model.service.CplbService;
import cn.gson.crm.model.service.FunTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/lb")
public class CplbController {
    @Autowired
    CplbService cplbService;
    @Autowired
    FunTypeService funTypeService;

    //查询级别
    @RequestMapping("/cx")
    @ResponseBody
    public List<Category> lb(String lbm){
        return cplbService.cx(lbm);
    }


    @RequestMapping("/lbid")
    @ResponseBody
    public List<Category> lei(Integer lbid){
        return cplbService.lei(lbid);
    }

    //新增
    @RequestMapping("/xz")
    @ResponseBody
    public void xin(@RequestBody categ categ){
        cplbService.cate(categ);
    }

    @RequestMapping("/idd")
    @ResponseBody
    public List<Category> lj(Integer idd){
        System.out.println("iddddddd:"+idd);
        return cplbService.lj(idd);
    }

    @RequestMapping("/iid")
    @ResponseBody
    public List<Category> lj1(Integer iid){
        System.out.println("iddddddd:"+iid);
        return cplbService.lj1(iid);
    }

    //删除
    @RequestMapping("/sc")
    @ResponseBody
    public void sc(Integer categoryId){
        System.out.println("111"+categoryId);
        cplbService.shan(categoryId);
    }

    //树形控件
    @RequestMapping("/sx")
    @ResponseBody
    public List<FunctionType> sx(){
        return funTypeService.allFunctionType();
    }

    //根据级别查询类别
    @RequestMapping("/jb")
    @ResponseBody
    public List<Category> jb(){
        return cplbService.jl();
    }

    //删除查询
    @RequestMapping("/shanchu")
    @ResponseBody
    public List<Category> shanchu(){
        return cplbService.shanchu();
    }


}
